%{

    #include "y.tab.h"

%}

blancs       [ \t\r\n]+

chiffre      [0-9]
entier       (-)?{chiffre}+
chaine       \"[a-zA-Z0-9_ \\=+*/:-]+\"

identifiant  [a-zA-Z][_'a-zA-Z0-9]*

%%


"program"|"PROGRAM"   return(PROGRAM);
"var"|"VAR"           return(VAR);
"unit"|"UNIT"         return(UNIT);
"bool"|"BOOL"         return(BOOL);
"int"|"INT"           return(INT);
"array"|"ARRAY"       return(ARRAY);
"["                   return(CROCHET_OUVRANT);
"]"                   return(CROCHET_FERMANT);
"of"|"OF"             return(OF);
".."                  return(RANGE_MARK);
";"                   return(POINT_VIRGULE);
"function"|"FUNCTION" return(FUNCTION);
"("                   return(PARENTHESE_OUVRANTE);
")"                   return(PARENTHESE_FERMANTE);
":"                   return(DOUBLE_POINT);
","                   return(VIRGULE);
"ref"|"REF"           return(REF);
"if"|"IF"             return(IF);
"then"|"THEN"         return(THEN);
"else"|"ELSE"         return(ELSE);
"while"|"WHILE"       return(WHILE);
"do"|"DO"             return(DO);
"return"|"RETURN"     return(RETURN);
"begin"|"BEGIN"       return(BBEGIN);
"end"|"END"           return(END);
"read"|"READ"         return(READ);
"write"|"WRITE"       return(WRITE);

":="        { yylval.operation = AFF;return(AFF); }
"+"         { yylval.operation = ADD;return(ADD); }
"-"         { yylval.operation = SUB;return(SUB); }
"*"         { yylval.operation = MUL;return(MUL); }
"/"         { yylval.operation = DIV;return(DIV); }
"^"         { yylval.operation = POW;return(POW); }
"<"         { yylval.operation = LT;return(LT); }
"<="        { yylval.operation = LET;return(LET); }
">"         { yylval.operation = GT;return(GT); }
">="        { yylval.operation = GET;return(GET); }
"="         { yylval.operation = EQ;return(EQ); }
"<>"        { yylval.operation = DIFF;return(DIFF); }
"and"|"AND" { yylval.operation = AND;return(AND); }
"or"|"OR"   { yylval.operation = OR;return(OR); }
"xor"|"XOR" { yylval.operation = XOR;return(XOR); }
"not"|"NOT" { yylval.operation = NOT;return(NOT); }


{identifiant} {
    yylval.identifiant = strdup( yytext );
    return(IDENT);
}

{chaine} {
    yylval.string = strdup( yytext );
    return(CTE);
}

{entier} {
    yylval.integer = atoi(yytext);
    return(INTEGER);
}


"(*".*"*)" { /* Commentaire => On ignore */ }
{blancs}   { /* On ignore */ }

%%
